package org.yuedu.util;

import io.smallrye.jwt.build.Jwt;

import java.time.Instant;
import java.time.temporal.ChronoUnit;

public class JwtUtil {
    private static final String ISSUER = "auth-service";

    public static String generateToken(String email, Integer userId) {
        Instant now = Instant.now();

        return Jwt.issuer(ISSUER)
                .subject(userId.toString())
                .upn(email)
                .issuedAt(now)
                .expiresAt(now.plus(24, ChronoUnit.HOURS)) // 24小时过期
                .sign();
    }
}